package com.itbupt.infrastructure.dao;

import com.itbupt.infrastructure.dao.po.GroupBuyOrderList;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * @Author dingchang
 * @Date 2025/4/28 18:42
 * @Description: 用户拼单明细持久化接口
 */

@Mapper
public interface IGroupBuyOrderListDao {

    /**
     * 插入一条拼单明细
     * @param groupBuyOrderListReq
     */
    void insert(GroupBuyOrderList groupBuyOrderListReq);

    /**
     * 根据单号查询已锁定的拼单明细
     * @param groupBuyOrderListReq
     * @return
     */
    GroupBuyOrderList queryGroupBuyOrderRecordByOutTradeNo(GroupBuyOrderList groupBuyOrderListReq);

    /**
     * 查询用户已经拼单的次数
     * @param groupBuyOrderListReq
     * @return
     */
    Integer queryOrderCountByActivityId(GroupBuyOrderList groupBuyOrderListReq);

    /**
     * 更新订单明细状态为complete
     * @param groupBuyOrderListReq
     * @return
     */
    int updateOrderStatus2COMPLETE(GroupBuyOrderList groupBuyOrderListReq);

    /**
     * 查询同一个组队拼团下的单号列表
     * @param teamId
     * @return
     */
    List<String> queryGroupBuyCompleteOrderOutTradeNoListByTeamId(String teamId);

    /**
     * 查询符合条件（活动未结束，状态为0，1）的拼单明细，排序，取出指定条数的记录
     * @param groupBuyOrderListReq
     * @return user_id, team_id, out_trade_no
     */
    List<GroupBuyOrderList> queryInProgressUserGroupBuyOrderDetailListByUserId(GroupBuyOrderList groupBuyOrderListReq);

    /**
     * 查询符合条件（活动未结束，状态为0的拼单明细，排序，取出指定条数的记录
     * @param groupBuyOrderListReq
     * @return
     */
    List<GroupBuyOrderList> queryInProgressUserGroupBuyOrderDetailListByRandom(GroupBuyOrderList groupBuyOrderListReq);

    /**
     * 查询拼团明细 - 根据活动id拿到队伍信息（team_Id等）
     * @param activityId
     * @return
     */
    List<GroupBuyOrderList> queryInProgressUserGroupBuyOrderDetailListByActivityId(Long activityId);

}
